Skip to content

Validate CLI execution_config before creating a run - #425

Merged
rquidute merged 2 commits into
project-chip:v2.17-developfrom
rquidute:fix/1210-validate-cli-execution-config-v2.17
Nov 24, 2026
Merged

rquidute merged 2 commits into
project-chip:v2.17-developfrom
rquidute:fix/1210-validate-cli-execution-config-v2.17

Conversation

@rquidute

Copy link
Copy Markdown
Contributor

Closes #1210

Problem

POST /test_run_executions/cli stored execution_config without validating it, unlike project create/update. A typo or wrong type in a th-cli run-tests --config file was only found after the run started.

Change

  • Extract the project validation into crud_project.validate_config() and reuse it in crud_project.create/update.
  • In create_cli_test_run_execution, validate execution_config (when provided) before the CLI project or the execution is created. A TestEnvironmentConfigError is returned as 422 with the message as detail.

Tests

  • Invalid config returns 422 and creates no project or execution.
  • Absent config is not validated.
  • Existing tests with a valid config cover the success path.

Not run locally (needs the Docker/DB dev environment).

CLI side: no code change needed (a 422 is already reported as APIError); regression test in the paired CLI PR.

create_cli_test_run_execution stored execution_config without validating
it, so a typo or wrong type was only found after the run started. Extract
the project validation into crud_project.validate_config and call it
before any project or execution is created, returning 422 on failure.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 909561d4-e291-4a5a-9d02-cece22c53a07

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Walkthrough

The change adds a shared configuration validator and uses it for project creation, project updates, and CLI test-run executions. When a supplied CLI execution_config fails validation, the endpoint returns HTTP 422 before retrieving or creating a project. Tests cover invalid and absent execution configurations.

Possibly related PRs

Suggested reviewers: antonio-amjr, greens

Severity of issue fixed: Medium

Merge Risk: Moderate · previous review a6f5f

The new CLI config validation looks correct, but one of its added tests builds an invalid mock response and fails CI. Fix the test fixture so the backend test suite passes before merging.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Backend requirements of #1210 are addressed. The change in test_run_executions.py validates execution_config when it is provided, before the CLI project or execution is created. TestEnvironmentConfigE… Confirm in this repository that the th_cli error path converts an HTTP 422 response from POST /test_run_executions/cli into a CLIError (or equivalent) before any SDK container starts. Confirm that a CLI test for this path exists at the revi…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: the CLI test-run endpoint now validates execution_config before a run or project is created. It matches the raw summary, the PR description, and the objectives.
Description check Passed The description states the problem (execution_config was stored without validation), the change (shared validate_config helper, 422 on TestEnvironmentConfigError), and the tests. This matches the chan…
Out of Scope Changes check Passed All changed areas connect to #1210. The changes are: (1) the CLI endpoint validation and 422 mapping in app/api/api_v1/endpoints/test_run_executions.py; (2) extraction of validate_config() in app/crud…
Full details: Description check

Explanation

The description states the problem (execution_config was stored without validation), the change (shared validate_config helper, 422 on TestEnvironmentConfigError), and the tests. This matches the changeset.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to #1210. The changes are: (1) the CLI endpoint validation and 422 mapping in app/api/api_v1/endpoints/test_run_executions.py; (2) extraction of validate_config() in app/crud/crud_project.py, reused by create and update, which the issue suggests as the shared validation helper; (3) backend tests for invalid and absent execution_config in app/tests/api/api_v1/test_test_run_executions.py. The refactor of project create and update is limited to replacing inline validation with the shared helper. It supports the issue approach and does not change unrelated behavior, based on the summary. No unrelated change was found.

Full details: Linked Issues check

Explanation

Backend requirements of #1210 are addressed. The change in test_run_executions.py validates execution_config when it is provided, before the CLI project or execution is created. TestEnvironmentConfigError maps to HTTP 422 with the message as detail. crud_project.validate_config() is shared with create and update. Tests cover invalid config (422, no project or execution created) and absent config (no validation). Valid config is covered by existing success-path tests. These results come from the PR summary and the PR description. Source inspection did not confirm them. The issue also requires that the CLI surfaces the error as a CLIError before any test starts, and that CLI test coverage exists. The PR states that no CLI change is needed because a 422 is already reported as APIError, and that the regression test is in a paired CLI PR. That paired PR is not part of this review. The CLI behavior is therefore not established by evidence in this PR. Related pull requests do not establish included work.

Resolution

Confirm in this repository that the th_cli error path converts an HTTP 422 response from POST /test_run_executions/cli into a CLIError (or equivalent) before any SDK container starts. Confirm that a CLI test for this path exists at the reviewed head or is included in this PR. If the paired CLI PR is the only location for that test, the issue reviewer must accept that split scope. Confirm the backend tests run and pass, because the PR states they were not run locally.

Finishing Touches

Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mergify

mergify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 10c2fdb7-6e79-4d4d-a2cd-0270dfc444b7
Commits

Reviewing files that changed from the base of the PR and between 89cb842 and a6f5fa0.

Files selected for processing: 3

  • app/api/api_v1/endpoints/test_run_executions.py
  • app/crud/crud_project.py
  • app/tests/api/api_v1/test_test_run_executions.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

"app.api.api_v1.endpoints.test_run_executions.crud.test_run_execution.create"
) as mock_create:
mock_cli_project.return_value = MagicMock(id=1, config={})
mock_create.return_value = MagicMock()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

Return a response-valid execution from this mock.

MagicMock() does not satisfy TestRunExecutionWithChildren. The supplied CI reports six response validation errors, so client.post() raises before the call assertions run. This fails the backend test command.

Return a valid execution fixture, as the neighboring success test does. Also assert HTTP 200 to confirm that the absent-config request completes successfully.

Source: Pipeline failures

@rquidute rquidute self-assigned this Nov 24, 2026
@rquidute
rquidute merged commit 8df6425 into project-chip:v2.17-develop Nov 24, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants